<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>firststrong_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_editor_plugins_firststrong_test.js.html">firststrong_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2012 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.editor.plugins.FirstStrongTest&#39;);
<a name="line16"></a>goog.setTestOnly(&#39;goog.editor.plugins.FirstStrongTest&#39;);
<a name="line17"></a>
<a name="line18"></a>goog.require(&#39;goog.dom.Range&#39;);
<a name="line19"></a>goog.require(&#39;goog.editor.Command&#39;);
<a name="line20"></a>goog.require(&#39;goog.editor.Field&#39;);
<a name="line21"></a>goog.require(&#39;goog.editor.plugins.FirstStrong&#39;);
<a name="line22"></a>goog.require(&#39;goog.editor.range&#39;);
<a name="line23"></a>goog.require(&#39;goog.events.KeyCodes&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.editor.TestHelper&#39;);
<a name="line25"></a>goog.require(&#39;goog.testing.events&#39;);
<a name="line26"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line27"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line28"></a>
<a name="line29"></a>// The key code for the Hebrew ?, a strongly RTL letter.
<a name="line30"></a>var ALEPH_KEYCODE = 1488;
<a name="line31"></a>
<a name="line32"></a>var field;
<a name="line33"></a>var fieldElement;
<a name="line34"></a>var dom;
<a name="line35"></a>var helper;
<a name="line36"></a>var triggeredCommand = null;
<a name="line37"></a>
<a name="line38"></a>function setUp() {
<a name="line39"></a>  field = new goog.editor.Field(&#39;field&#39;);
<a name="line40"></a>  field.registerPlugin(new goog.editor.plugins.FirstStrong());
<a name="line41"></a>  field.makeEditable();
<a name="line42"></a>
<a name="line43"></a>  fieldElement = field.getElement();
<a name="line44"></a>
<a name="line45"></a>  helper = new goog.testing.editor.TestHelper(fieldElement);
<a name="line46"></a>
<a name="line47"></a>  dom = field.getEditableDomHelper();
<a name="line48"></a>
<a name="line49"></a>  // Mock out execCommand to see if a direction change has been triggered.
<a name="line50"></a>  field.execCommand = function(command) {
<a name="line51"></a>    if (command == goog.editor.Command.DIR_LTR ||
<a name="line52"></a>        command == goog.editor.Command.DIR_RTL)
<a name="line53"></a>      triggeredCommand = command;
<a name="line54"></a>  };
<a name="line55"></a>}
<a name="line56"></a>
<a name="line57"></a>function tearDown() {
<a name="line58"></a>  triggeredCommand = null;
<a name="line59"></a>}
<a name="line60"></a>
<a name="line61"></a>function testFirstCharacter_RTL() {
<a name="line62"></a>  field.setHtml(false, &#39;&lt;div id=&quot;text&quot;&gt;&amp;nbsp;&lt;/div&gt;&#39;);
<a name="line63"></a>  field.focusAndPlaceCursorAtStart();
<a name="line64"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line65"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line66"></a>  assertRTL();
<a name="line67"></a>}
<a name="line68"></a>
<a name="line69"></a>function testFirstCharacter_LTR() {
<a name="line70"></a>  field.setHtml(false, &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt;&amp;nbsp;&lt;/div&gt;&#39;);
<a name="line71"></a>  field.focusAndPlaceCursorAtStart();
<a name="line72"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line73"></a>      goog.events.KeyCodes.A);
<a name="line74"></a>  assertLTR();
<a name="line75"></a>}
<a name="line76"></a>
<a name="line77"></a>function testFirstStrongCharacter_RTL() {
<a name="line78"></a>  field.setHtml(false, &#39;&lt;div id=&quot;text&quot;&gt;123.7 3121, &lt;b&gt;&lt;++{}&gt;&lt;/b&gt; - $45&lt;/div&gt;&#39;);
<a name="line79"></a>  field.focusAndPlaceCursorAtStart();
<a name="line80"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line81"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line82"></a>  assertRTL();
<a name="line83"></a>}
<a name="line84"></a>
<a name="line85"></a>function testFirstStrongCharacter_LTR() {
<a name="line86"></a>  field.setHtml(false,
<a name="line87"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt;123.7 3121, &lt;b&gt;&lt;++{}&gt;&lt;/b&gt; - $45&lt;/div&gt;&#39;);
<a name="line88"></a>  field.focusAndPlaceCursorAtStart();
<a name="line89"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line90"></a>      goog.events.KeyCodes.A);
<a name="line91"></a>  assertLTR();
<a name="line92"></a>}
<a name="line93"></a>
<a name="line94"></a>function testNotStrongCharacter_RTL() {
<a name="line95"></a>  field.setHtml(false, &#39;&lt;div id=&quot;text&quot;&gt;123.7 3121, - $45&lt;/div&gt;&#39;);
<a name="line96"></a>  field.focusAndPlaceCursorAtStart();
<a name="line97"></a>  goog.testing.events.fireKeySequence(fieldElement, goog.events.KeyCodes.NINE);
<a name="line98"></a>  assertNoCommand();
<a name="line99"></a>}
<a name="line100"></a>
<a name="line101"></a>function testNotStrongCharacter_LTR() {
<a name="line102"></a>  field.setHtml(false, &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt;123.7 3121 $45&lt;/div&gt;&#39;);
<a name="line103"></a>  field.focusAndPlaceCursorAtStart();
<a name="line104"></a>  goog.testing.events.fireKeySequence(fieldElement, goog.events.KeyCodes.NINE);
<a name="line105"></a>  assertNoCommand();
<a name="line106"></a>}
<a name="line107"></a>
<a name="line108"></a>function testNotFirstStrongCharacter_RTL() {
<a name="line109"></a>  field.setHtml(false, &#39;&lt;div id=&quot;text&quot;&gt;123.7 3121, &lt;b&gt;English&lt;/b&gt; - $45&lt;/div&gt;&#39;);
<a name="line110"></a>  field.focusAndPlaceCursorAtStart();
<a name="line111"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line112"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line113"></a>  assertNoCommand();
<a name="line114"></a>}
<a name="line115"></a>
<a name="line116"></a>function testNotFirstStrongCharacter_LTR() {
<a name="line117"></a>  field.setHtml(false,
<a name="line118"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt;123.7 3121, &lt;b&gt;?????&lt;/b&gt; - $45&lt;/div&gt;&#39;);
<a name="line119"></a>  field.focusAndPlaceCursorAtStart();
<a name="line120"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line121"></a>      goog.events.KeyCodes.A);
<a name="line122"></a>  assertNoCommand();
<a name="line123"></a>}
<a name="line124"></a>
<a name="line125"></a>function testFirstStrongCharacterWithInnerDiv_RTL() {
<a name="line126"></a>  field.setHtml(false,
<a name="line127"></a>      &#39;&lt;div id=&quot;text&quot;&gt;123.7 3121, &lt;b id=&quot;b&quot;&gt;&lt;++{}&gt;&lt;/b&gt;&#39; +
<a name="line128"></a>      &#39;&lt;div id=&quot;inner&quot;&gt;English&lt;/div&gt;&#39; +
<a name="line129"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line130"></a>  field.focusAndPlaceCursorAtStart();
<a name="line131"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line132"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line133"></a>  assertRTL();
<a name="line134"></a>}
<a name="line135"></a>
<a name="line136"></a>function testFirstStrongCharacterWithInnerDiv_LTR() {
<a name="line137"></a>  field.setHtml(false,
<a name="line138"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt;123.7 3121, &lt;b id=&quot;b&quot;&gt;&lt;++{}&gt;&lt;/b&gt;&#39; +
<a name="line139"></a>      &#39;&lt;div id=&quot;inner&quot;&gt;English&lt;/div&gt;&#39; +
<a name="line140"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line141"></a>  field.focusAndPlaceCursorAtStart();
<a name="line142"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line143"></a>      goog.events.KeyCodes.A);
<a name="line144"></a>  assertLTR();
<a name="line145"></a>}
<a name="line146"></a>
<a name="line147"></a>
<a name="line148"></a>/**
<a name="line149"></a> * Regression for {@link http://b/7549696}
<a name="line150"></a> */
<a name="line151"></a>function testFirstStrongCharacterInNewLine_RTL() {
<a name="line152"></a>  field.setHtml(false, &#39;&lt;div&gt;&lt;b id=&quot;cur&quot;&gt;English&lt;br&gt;1&lt;/b&gt;&lt;/div&gt;&#39;);
<a name="line153"></a>  goog.dom.Range.createCaret(dom.$(&#39;cur&#39;), 2).select();
<a name="line154"></a>
<a name="line155"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line156"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line157"></a>  // Only GECKO treats &lt;br&gt; as a new paragraph.
<a name="line158"></a>  if (goog.userAgent.GECKO) {
<a name="line159"></a>    assertRTL();
<a name="line160"></a>  } else {
<a name="line161"></a>    assertNoCommand();
<a name="line162"></a>  }
<a name="line163"></a>}
<a name="line164"></a>
<a name="line165"></a>function testFirstStrongCharacterInParagraph_RTL() {
<a name="line166"></a>  field.setHtml(false,
<a name="line167"></a>      &#39;&lt;div id=&quot;text1&quot;&gt;1&amp;gt; English&lt;/div&gt;&#39; +
<a name="line168"></a>      &#39;&lt;div id=&quot;text2&quot;&gt;2&amp;gt;&lt;/div&gt;&#39; +
<a name="line169"></a>      &#39;&lt;div id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line170"></a>  goog.dom.Range.createCaret(dom.$(&#39;text2&#39;), 0).select();
<a name="line171"></a>
<a name="line172"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line173"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line174"></a>  assertRTL();
<a name="line175"></a>}
<a name="line176"></a>
<a name="line177"></a>function testFirstStrongCharacterInParagraph_LTR() {
<a name="line178"></a>  field.setHtml(false,
<a name="line179"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text1&quot;&gt;1&amp;gt; ?????&lt;/div&gt;&#39; +
<a name="line180"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text2&quot;&gt;2&amp;gt;&lt;/div&gt;&#39; +
<a name="line181"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line182"></a>  goog.dom.Range.createCaret(dom.$(&#39;text2&#39;), 0).select();
<a name="line183"></a>
<a name="line184"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line185"></a>      goog.events.KeyCodes.A);
<a name="line186"></a>  assertLTR();
<a name="line187"></a>}
<a name="line188"></a>
<a name="line189"></a>function testFirstStrongCharacterInList_RTL() {
<a name="line190"></a>  field.setHtml(false,
<a name="line191"></a>      &#39;&lt;div id=&quot;text1&quot;&gt;1&amp;gt; English&lt;/div&gt;&#39; +
<a name="line192"></a>      &#39;&lt;ul id=&quot;list&quot;&gt;&#39; +
<a name="line193"></a>      &#39;&lt;li&gt;10&amp;gt;&lt;/li&gt;&#39; +
<a name="line194"></a>      &#39;&lt;li id=&quot;li2&quot;&gt;&lt;/li&gt;&#39; +
<a name="line195"></a>      &#39;&lt;li&gt;30&lt;/li&gt;&#39; +
<a name="line196"></a>      &#39;&lt;/ul&gt;&#39; +
<a name="line197"></a>      &#39;&lt;div id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line198"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;li2&#39;), true);
<a name="line199"></a>
<a name="line200"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line201"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line202"></a>  assertRTL();
<a name="line203"></a>}
<a name="line204"></a>
<a name="line205"></a>function testFirstStrongCharacterInList_LTR() {
<a name="line206"></a>  field.setHtml(false,
<a name="line207"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text1&quot;&gt;1&amp;gt; English&lt;/div&gt;&#39; +
<a name="line208"></a>      &#39;&lt;ul dir=&quot;rtl&quot; id=&quot;list&quot;&gt;&#39; +
<a name="line209"></a>      &#39;&lt;li&gt;10&amp;gt;&lt;/li&gt;&#39; +
<a name="line210"></a>      &#39;&lt;li id=&quot;li2&quot;&gt;&lt;/li&gt;&#39; +
<a name="line211"></a>      &#39;&lt;li&gt;30&lt;/li&gt;&#39; +
<a name="line212"></a>      &#39;&lt;/ul&gt;&#39; +
<a name="line213"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line214"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;li2&#39;), true);
<a name="line215"></a>
<a name="line216"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line217"></a>      goog.events.KeyCodes.A);
<a name="line218"></a>  assertLTR();
<a name="line219"></a>}
<a name="line220"></a>
<a name="line221"></a>function testNotFirstStrongCharacterInList_RTL() {
<a name="line222"></a>  field.setHtml(false,
<a name="line223"></a>      &#39;&lt;div id=&quot;text1&quot;&gt;1&lt;/div&gt;&#39; +
<a name="line224"></a>      &#39;&lt;ul id=&quot;list&quot;&gt;&#39; +
<a name="line225"></a>      &#39;&lt;li&gt;10&amp;gt;&lt;/li&gt;&#39; +
<a name="line226"></a>      &#39;&lt;li id=&quot;li2&quot;&gt;&lt;/li&gt;&#39; +
<a name="line227"></a>      &#39;&lt;li&gt;30&lt;b&gt;3&lt;i&gt;Hidden English&lt;/i&gt;32&lt;/b&gt;&lt;/li&gt;&#39; +
<a name="line228"></a>      &#39;&lt;/ul&gt;&#39; +
<a name="line229"></a>      &#39;&lt;div id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line230"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;li2&#39;), true);
<a name="line231"></a>
<a name="line232"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line233"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line234"></a>  assertNoCommand();
<a name="line235"></a>}
<a name="line236"></a>
<a name="line237"></a>function testNotFirstStrongCharacterInList_LTR() {
<a name="line238"></a>  field.setHtml(false,
<a name="line239"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text1&quot;&gt;1&amp;gt; English&lt;/div&gt;&#39; +
<a name="line240"></a>      &#39;&lt;ul dir=&quot;rtl&quot; id=&quot;list&quot;&gt;&#39; +
<a name="line241"></a>      &#39;&lt;li&gt;10&amp;gt;&lt;/li&gt;&#39; +
<a name="line242"></a>      &#39;&lt;li id=&quot;li2&quot;&gt;&lt;/li&gt;&#39; +
<a name="line243"></a>      &#39;&lt;li&gt;30&lt;b&gt;3&lt;i&gt;????? ?????&lt;/i&gt;32&lt;/b&gt;&lt;/li&gt;&#39; +
<a name="line244"></a>      &#39;&lt;/ul&gt;&#39; +
<a name="line245"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text3&quot;&gt;3&amp;gt;&lt;/div&gt;&#39;);
<a name="line246"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;li2&#39;), true);
<a name="line247"></a>
<a name="line248"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line249"></a>      goog.events.KeyCodes.A);
<a name="line250"></a>  assertNoCommand();
<a name="line251"></a>}
<a name="line252"></a>
<a name="line253"></a>function testFirstStrongCharacterWithBR_RTL() {
<a name="line254"></a>  field.setHtml(false,
<a name="line255"></a>      &#39;&lt;div id=&quot;container&quot;&gt;&#39; +
<a name="line256"></a>      &#39;&lt;div id=&quot;text1&quot;&gt;ABC&lt;/div&gt;&#39; +
<a name="line257"></a>      &#39;&lt;div id=&quot;text2&quot;&gt;&#39; +
<a name="line258"></a>          &#39;1&lt;br&gt;&#39; +
<a name="line259"></a>          &#39;2&lt;b id=&quot;inner&quot;&gt;3&lt;/b&gt;&lt;i&gt;4&lt;u&gt;5&lt;br&gt;&#39; +
<a name="line260"></a>          &#39;6&lt;/u&gt;7&lt;/i&gt;8&lt;/b&gt;9&lt;br&gt;&#39; +
<a name="line261"></a>          &#39;10&#39; +
<a name="line262"></a>      &#39;&lt;/div&gt;&#39; +
<a name="line263"></a>      &#39;&lt;div id=&quot;text3&quot;&gt;11&lt;/div&gt;&#39; +
<a name="line264"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line265"></a>
<a name="line266"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;inner&#39;), true);
<a name="line267"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line268"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line269"></a>  assertRTL();
<a name="line270"></a>}
<a name="line271"></a>
<a name="line272"></a>function testFirstStrongCharacterWithBR_LTR() {
<a name="line273"></a>  field.setHtml(false,
<a name="line274"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;container&quot;&gt;&#39; +
<a name="line275"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text1&quot;&gt;???&lt;/div&gt;&#39; +
<a name="line276"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text2&quot;&gt;&#39; +
<a name="line277"></a>          &#39;1&lt;br&gt;&#39; +
<a name="line278"></a>          &#39;2&lt;b id=&quot;inner&quot;&gt;3&lt;/b&gt;&lt;i&gt;4&lt;u&gt;5&lt;br&gt;&#39; +
<a name="line279"></a>          &#39;6&lt;/u&gt;7&lt;/i&gt;8&lt;/b&gt;9&lt;br&gt;&#39; +
<a name="line280"></a>          &#39;10&#39; +
<a name="line281"></a>      &#39;&lt;/div&gt;&#39; +
<a name="line282"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text3&quot;&gt;11&lt;/div&gt;&#39; +
<a name="line283"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line284"></a>
<a name="line285"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;inner&#39;), true);
<a name="line286"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line287"></a>      goog.events.KeyCodes.A);
<a name="line288"></a>  assertLTR();
<a name="line289"></a>}
<a name="line290"></a>
<a name="line291"></a>function testNotFirstStrongCharacterInBR_RTL() {
<a name="line292"></a>  field.setHtml(false,
<a name="line293"></a>      &#39;&lt;div id=&quot;container&quot;&gt;&#39; +
<a name="line294"></a>      &#39;&lt;div id=&quot;text1&quot;&gt;ABC&lt;/div&gt;&#39; +
<a name="line295"></a>      &#39;&lt;div id=&quot;text2&quot;&gt;&#39; +
<a name="line296"></a>          &#39;1&lt;br&gt;&#39; +
<a name="line297"></a>          &#39;2&lt;b id=&quot;inner&quot;&gt;3&lt;/b&gt;&lt;i&gt;&lt;em&gt;4G&lt;/em&gt;&lt;u&gt;5&lt;br&gt;&#39; +
<a name="line298"></a>          &#39;6&lt;/u&gt;7&lt;/i&gt;8&lt;/b&gt;9&lt;br&gt;&#39; +
<a name="line299"></a>          &#39;10&#39; +
<a name="line300"></a>      &#39;&lt;/div&gt;&#39; +
<a name="line301"></a>      &#39;&lt;div id=&quot;text3&quot;&gt;11&lt;/div&gt;&#39; +
<a name="line302"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line303"></a>
<a name="line304"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;inner&#39;), true);
<a name="line305"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line306"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line307"></a>  assertNoCommand();
<a name="line308"></a>}
<a name="line309"></a>
<a name="line310"></a>function testNotFirstStrongCharacterInBR_LTR() {
<a name="line311"></a>  field.setHtml(false,
<a name="line312"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;container&quot;&gt;&#39; +
<a name="line313"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text1&quot;&gt;ABC&lt;/div&gt;&#39; +
<a name="line314"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text2&quot;&gt;&#39; +
<a name="line315"></a>          &#39;1&lt;br&gt;&#39; +
<a name="line316"></a>          &#39;2&lt;b id=&quot;inner&quot;&gt;3&lt;/b&gt;&lt;i&gt;&lt;em&gt;4G&lt;/em&gt;&lt;u&gt;5&lt;br&gt;&#39; +
<a name="line317"></a>          &#39;6&lt;/u&gt;7&lt;/i&gt;8&lt;/b&gt;9&lt;br&gt;&#39; +
<a name="line318"></a>          &#39;10&#39; +
<a name="line319"></a>      &#39;&lt;/div&gt;&#39; +
<a name="line320"></a>      &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text3&quot;&gt;11&lt;/div&gt;&#39; +
<a name="line321"></a>      &#39;&lt;/div&gt;&#39;);
<a name="line322"></a>
<a name="line323"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;inner&#39;), true);
<a name="line324"></a>  goog.testing.events.fireKeySequence(fieldElement,
<a name="line325"></a>      goog.events.KeyCodes.A);
<a name="line326"></a>  assertNoCommand();
<a name="line327"></a>}
<a name="line328"></a>
<a name="line329"></a>
<a name="line330"></a>/**
<a name="line331"></a> * Regression for {@link http://b/7530985}
<a name="line332"></a> */
<a name="line333"></a>function testFirstStrongCharacterWithPreviousBlockSibling_RTL() {
<a name="line334"></a>  field.setHtml(false, &#39;&lt;div&gt;Te&lt;div&gt;xt&lt;/div&gt;1&lt;b id=&quot;cur&quot;&gt;2&lt;/b&gt;3&lt;/div&gt;&#39;);
<a name="line335"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;cur&#39;), true);
<a name="line336"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line337"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line338"></a>  assertRTL();
<a name="line339"></a>}
<a name="line340"></a>
<a name="line341"></a>function testFirstStrongCharacterWithPreviousBlockSibling_LTR() {
<a name="line342"></a>  field.setHtml(
<a name="line343"></a>      false, &#39;&lt;div dir=&quot;rtl&quot;&gt;??&lt;div&gt;??&lt;/div&gt;1&lt;b id=&quot;cur&quot;&gt;2&lt;/b&gt;3&lt;/div&gt;&#39;);
<a name="line344"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;cur&#39;), true);
<a name="line345"></a>  goog.testing.events.fireKeySequence(fieldElement, goog.events.KeyCodes.A);
<a name="line346"></a>  assertLTR();
<a name="line347"></a>}
<a name="line348"></a>
<a name="line349"></a>function testFirstStrongCharacterWithFollowingBlockSibling_RTL() {
<a name="line350"></a>  field.setHtml(false, &#39;&lt;div&gt;1&lt;b id=&quot;cur&quot;&gt;2&lt;/b&gt;3&lt;div&gt;Te&lt;/div&gt;xt&lt;/div&gt;&#39;);
<a name="line351"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;cur&#39;), true);
<a name="line352"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement,
<a name="line353"></a>      goog.events.KeyCodes.T, ALEPH_KEYCODE);
<a name="line354"></a>  assertRTL();
<a name="line355"></a>}
<a name="line356"></a>
<a name="line357"></a>function testFirstStrongCharacterWithFollowingBlockSibling_RTL() {
<a name="line358"></a>  field.setHtml(false, &#39;&lt;div dir=&quot;rtl&quot;&gt;1&lt;b id=&quot;cur&quot;&gt;2&lt;/b&gt;3&lt;div&gt;?&lt;/div&gt;?&lt;/div&gt;&#39;);
<a name="line359"></a>  goog.editor.range.placeCursorNextTo(dom.$(&#39;cur&#39;), true);
<a name="line360"></a>  goog.testing.events.fireKeySequence(fieldElement, goog.events.KeyCodes.A);
<a name="line361"></a>  assertLTR();
<a name="line362"></a>}
<a name="line363"></a>
<a name="line364"></a>function testFirstStrongCharacterFromIME_RTL() {
<a name="line365"></a>  field.setHtml(false, &#39;&lt;div id=&quot;text&quot;&gt;123.7 3121, &lt;/div&gt;&#39;);
<a name="line366"></a>  field.focusAndPlaceCursorAtStart();
<a name="line367"></a>  var attributes = {};
<a name="line368"></a>  attributes[goog.editor.plugins.FirstStrong.INPUT_ATTRIBUTE] = &#39;???&#39;;
<a name="line369"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement, 0, 0, attributes);
<a name="line370"></a>  if (goog.userAgent.IE) {
<a name="line371"></a>    // goog.testing.events.fireNonAsciiKeySequence doesn&#39;t send KEYPRESS event
<a name="line372"></a>    // so no command is expected.
<a name="line373"></a>    assertNoCommand();
<a name="line374"></a>  } else {
<a name="line375"></a>    assertRTL();
<a name="line376"></a>  }
<a name="line377"></a>}
<a name="line378"></a>
<a name="line379"></a>function testFirstCharacterFromIME_LTR() {
<a name="line380"></a>  field.setHtml(false, &#39;&lt;div dir=&quot;rtl&quot; id=&quot;text&quot;&gt; 1234 &lt;/div&gt;&#39;);
<a name="line381"></a>  field.focusAndPlaceCursorAtStart();
<a name="line382"></a>  var attributes = {};
<a name="line383"></a>  attributes[goog.editor.plugins.FirstStrong.INPUT_ATTRIBUTE] = &#39;ABC&#39;;
<a name="line384"></a>  goog.testing.events.fireNonAsciiKeySequence(fieldElement, 0, 0, attributes);
<a name="line385"></a>  if (goog.userAgent.IE) {
<a name="line386"></a>    // goog.testing.events.fireNonAsciiKeySequence doesn&#39;t send KEYPRESS event
<a name="line387"></a>    // so no command is expected.
<a name="line388"></a>    assertNoCommand();
<a name="line389"></a>  } else {
<a name="line390"></a>    assertLTR();
<a name="line391"></a>  }
<a name="line392"></a>}
<a name="line393"></a>
<a name="line394"></a>function assertRTL() {
<a name="line395"></a>  assertEquals(goog.editor.Command.DIR_RTL, triggeredCommand);
<a name="line396"></a>}
<a name="line397"></a>
<a name="line398"></a>function assertLTR() {
<a name="line399"></a>  assertEquals(goog.editor.Command.DIR_LTR, triggeredCommand);
<a name="line400"></a>}
<a name="line401"></a>
<a name="line402"></a>function assertNoCommand() {
<a name="line403"></a>  assertNull(triggeredCommand);
<a name="line404"></a>}
</pre>


</body>
</html>
